const privacys = localStorage.getItem("privacyList")
const init = {
  privacyList:privacys? JSON.parse(privacys) : {} // 读取本地存储
};

export default function privacy(state = init, action) {
  let newState = { ...state };
  const { type, payload } = action;
  switch (type) {
    case "all":
      newState.privacyList = payload;
      break;
    default:
      return state;
  }
  // **保存到 localStorage**
  if(newState.privacyList){
    localStorage.setItem("privacyList", JSON.stringify(newState.privacyList));
  }
  return newState;
}